<%@ page import="com.hhm.pojo.Sex" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <link href="/static/css/index2.css" rel="stylesheet">
    <script type="text/javascript" src="/static/js/jquery-3.2.1.js"></script>
    <script>
        //删除
        function del(id) {
            if (confirm("确定要删除吗")){
                $.post(
                    "/del",
                    {id:id},
                    function (msg) {
                        if (msg){
                            alert("删除成功");
                            location.reload();
                        }else {
                            alert("删除no");
                        }
                    }
                );
            }
        }

    </script>
</head>
<body>
<form method="post" action="/list">
    生日区间：<input type="date" name="start" value="${user.start}"/>-
            <input type="date" name="end" value="${user.end}"/>
    <button>查询</button>
</form>
<table>
    <tr>
        <th>编号</th>
        <th>用户名</th>
        <th>密码</th>
        <th>性别</th>
        <th>手机号</th>
        <th>生日</th>
        <th>操作</th>
    </tr>
    <c:forEach items="${pg.list}" var="l">
        <tr>
            <td>${l.id}</td>
            <td>${l.username}</td>
            <td>${l.password}</td>
            <td>
                ${l.sex.name}
            </td>
            <td>${l.telephone}</td>
            <td>
                <fmt:formatDate value="${l.birthday}" pattern="yyyy-MM-dd"></fmt:formatDate>
            </td>
            <td>
                <a href="/selectOne?id=${l.id}">修改</a>
                <input type="button" value="删除" onclick="del(${l.id})"/>
            </td>
        </tr>
    </c:forEach>
</table>
<!--分页jsp-->
<jsp:include page="/static/common/pages.jsp"/>
</body>
</html>